package com.edwin.websitebe.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.edwin.websitebe.mapper.CustomerMapper;
import com.edwin.websitebe.model.Customer;
import com.edwin.websitebe.model.Sample;
import com.edwin.websitebe.service.CustomerService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
    @Override
    public Page<Customer> pageList(Customer customer) {
        LambdaQueryWrapper<Customer> wrapper = new QueryWrapper<Customer>().lambda()
                .like(StringUtils.isNotEmpty(customer.getCustomerName()), Customer::getCustomerName, customer.getCustomerName())
                .orderByDesc(Customer::getCreateTime);
        return this.page(Page.of(customer.getPage(), customer.getPageSize()), wrapper);
    }
}
